﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;
using System.Windows.Forms;

namespace Quaack
{
    public class LeesData
    {
        public bool FindEmail(String myString)
        {
            SqlConnection connection = new SqlConnection();
            connection.ConnectionString = "Server=.\\sqlexpress;Initial Catalog=Quaack;Integrated Security=True;MultipleActiveResultSets=True;Application Name=EntityFramework";
            SqlCommand command = new SqlCommand();
            command.Connection = connection;
            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = "FindEmail";
            command.Parameters.AddWithValue("@MyString", myString);
            try
            {
                connection.Open();
                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    return true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                if (connection.State == ConnectionState.Open)
                    connection.Close();
            }
            return false;
        }

        public bool FindUser(string myString)
        {
            SqlConnection connection = new SqlConnection();
            connection.ConnectionString = "Server=.\\sqlexpress;Initial Catalog=Quaack;Integrated Security=True;MultipleActiveResultSets=True;Application Name=EntityFramework";
            SqlCommand command = new SqlCommand();
            command.Connection = connection;
            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = "FindUser";
            command.Parameters.AddWithValue("@MyString", myString);
            try
            {
                connection.Open();
                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    return true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                if (connection.State == ConnectionState.Open)
                    connection.Close();
            }
            return false;
        }

        public bool FindMobile(string myString)
        {
            SqlConnection connection = new SqlConnection();
            connection.ConnectionString = "Server=.\\sqlexpress;Initial Catalog=Quaack;Integrated Security=True;MultipleActiveResultSets=True;Application Name=EntityFramework";
            SqlCommand command = new SqlCommand();
            command.Connection = connection;
            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = "FindMobile";
            command.Parameters.AddWithValue("@MyString", myString);
            try
            {
                connection.Open();
                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    return true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                if (connection.State == ConnectionState.Open)
                    connection.Close();
            }
            return false;
        }

        public bool FindProfileID(string myString)
        {
            SqlConnection connection = new SqlConnection();
            connection.ConnectionString = "Server=.\\sqlexpress;Initial Catalog=Quaack;Integrated Security=True;MultipleActiveResultSets=True;Application Name=EntityFramework";
            SqlCommand command = new SqlCommand();
            command.Connection = connection;
            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = "ProfileID";
            command.Parameters.AddWithValue("@MyString", myString);
            try
            {
                connection.Open();
                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    return true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                if (connection.State == ConnectionState.Open)
                    connection.Close();
            }
            return false;
        }
    }
}